import request from "./request";
export function userLogin(userObj) {//用户登录
  return request.post(("/login"),{
    "username":userObj.username,
    "password":userObj.password,
  })
}
//用户注册
export function userRegister(userObj) {
  return request.post(('add_user'),{
    "username":userObj.username,
    "password":userObj.password,
    "nickname":userObj.nickname,
    "userPortrait":userObj.adminIcon,
    "realName":userObj.realName,
    "userSex":userObj.sex,
  })
}
//根据userName获取用户的详细信息
export function getUserById(userId) {
  return request.get(`find_user_by_id?id=${userId}`)
}
//用户修改自己的信息
export function updateUser(userObj) {
  return request.post('update_user',userObj);
}
//获取全部书籍
export function getAllBooks() {
  return request.get("find_all_book");
}
//分页查询图书
export function findBookByLimit(pagenumber,limit) {
  console.log(pagenumber,limit)
  return request.get('find_book_by_limit',{
    params:{
      pageNum:pagenumber,
      limit
    }
  })
}
//获取轮播图信息
export  function getCarousel() {
  return request.get("find_all_lun_bo")
}
// 根据isbn查询书籍详情
// export function getBookByIsbn(isbn){
//   return request.post('/api/book/findbyisbn',{
//     isbn,
//   })
// }
export function getBookByIsbn(isbn){
  return request.get(`find_book_by_isbn?isbn=${isbn}`)
}
//添加借阅信息
export function addBorrow(userId,isbn) {
  return request.post("add_borrow",{
    userId,
    isbn,
  })
}
//查询用户的借阅记录
export function getBorrowByUserId(userId) {
  return request.get(`find_borrow_by_user_id?userId=${userId}`);
}

